package leecode

func minimumSum(n int, k int) int {
	ans := make([]int, 0, n)
	var result int
	hashMap := make(map[int]bool)
	for i := 1; len(ans) != n; i++ {
		if hashMap[i] {
			//如果哈希表中存在指定元素,则不能添加到切片中
			continue
		}
		hashMap[k-i] = true
		ans = append(ans, i)

	}
	for i := 0; i < len(ans); i++ {
		result += ans[i]
	}
	return result
}
